home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / DeskBus.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  6.4 KB  |  180 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        DeskBus.p
  3.  
  4.      Contains:    Apple Desktop Bus (ADB) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1987-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT DeskBus;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __DESKBUS__}
  28. {$SETC __DESKBUS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC DeskBusIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __MIXEDMODE__}
  38. {$I MixedMode.p}
  39. {$ENDC}
  40.  
  41.  
  42. {$PUSH}
  43. {$ALIGN MAC68K}
  44. {$LibExport+}
  45.  
  46.  
  47. TYPE
  48.     ADBAddress                            = SInt8;
  49.     ADBCompletionProcPtr = Register68kProcPtr;  { PROCEDURE ADBCompletion(buffer: Ptr; refCon: Ptr; command: LONGINT); }
  50.  
  51.     ADBDeviceDriverProcPtr = Register68kProcPtr;  { PROCEDURE ADBDeviceDriver(devAddress: SInt8; devType: SInt8); }
  52.  
  53. {
  54.     TempADBServiceRoutineUPP is needed because of circular definition of
  55.     ADBServiceRoutineProcPtr and ADBServiceRoutineUpp depending on each other.
  56. }
  57.     TempADBServiceRoutineUPP            = ProcPtr;
  58.     ADBServiceRoutineProcPtr = Register68kProcPtr;  { PROCEDURE ADBServiceRoutine(buffer: Ptr; completionProc: TempADBServiceRoutineUPP; refCon: Ptr; command: LONGINT); }
  59.  
  60.     ADBCompletionUPP = UniversalProcPtr;
  61.     ADBDeviceDriverUPP = UniversalProcPtr;
  62.     ADBServiceRoutineUPP = UniversalProcPtr;
  63. {
  64.     typedef pascal void (*ADBInitProcPtr)(SInt8 callOrder);
  65.  
  66.     Note: ADBInitProcPtr can only be created in 68K assembly language 
  67.           since it is a head patch that must JUMP to the previous address
  68. }
  69.     ADBDataBlockPtr = ^ADBDataBlock;
  70.     ADBDataBlock = PACKED RECORD
  71.         devType:                SInt8;                                    {  original handler ID  }
  72.         origADBAddr:            SInt8;                                    {  original ADB Address  }
  73.         dbServiceRtPtr:            ADBServiceRoutineUPP;                    {  service routine pointer  }
  74.         dbDataAreaAddr:            Ptr;                                    {  this field is passed as the refCon parameter to the service routine  }
  75.     END;
  76.  
  77.     ADBDBlkPtr                            = ^ADBDataBlock;
  78.     ADBSetInfoBlockPtr = ^ADBSetInfoBlock;
  79.     ADBSetInfoBlock = RECORD
  80.         siService:                ADBServiceRoutineUPP;                    {  service routine pointer  }
  81.         siDataAreaAddr:            Ptr;                                    {  this field is passed as the refCon parameter to the service routine  }
  82.     END;
  83.  
  84.     ADBSInfoPtr                            = ^ADBSetInfoBlock;
  85. { ADBOpBlock is only used when calling ADBOp from 68k assembly code }
  86.     ADBOpBlockPtr = ^ADBOpBlock;
  87.     ADBOpBlock = RECORD
  88.         dataBuffPtr:            Ptr;                                    {  buffer: pointer to variable length data buffer  }
  89.         opServiceRtPtr:            ADBServiceRoutineUPP;                    {  completionProc: completion routine pointer  }
  90.         opDataAreaPtr:            Ptr;                                    {  refCon: this field is passed as the refCon parameter to the completion routine  }
  91.     END;
  92.  
  93.     ADBOpBPtr                            = ^ADBOpBlock;
  94. PROCEDURE ADBReInit;
  95.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  96.     INLINE $A07B;
  97.     {$ENDC}
  98. {
  99.     ADBOp has a different interface for 68k assembly than for everything else
  100.     for 68k assembly the interface is 
  101.     #pragma parameter __D0 ADBOp(__A0,__D0)
  102.     OSErr ADBOp( ADBOpBlock * pb, short commandNum );
  103. }
  104. {
  105.     IMPORTANT NOTE:
  106.     "Inside Macintosh: Devices" documents the completion routine for ADBOp will be called with
  107.     four parameters using 68k register based calling conventions, specifically the completion routine
  108.     passed in should be of type ADBServiceRoutineProcPtr. However, when upp types were first added
  109.     to this interface file, the type ADBCompletionUPP was mistakenly used for the second parameter
  110.     to ADBOp. Since applications have shipped using completion routines of type ADBCompletionUPP,
  111.     the mistake cannot be corrected.
  112.     The only difference between ADBServiceRoutineUPP and ADBCompletionUPP is the former takes an extra
  113.     argument which is a pointer to itself, fortunately not needed for PowerPC code.
  114.     For compatibility with existing 68k code, when an ADBOp completion routine is called,
  115.     68k register A1 will point to the completion routine, as documented in Inside Mac.
  116. }
  117. FUNCTION ADBOp(refCon: Ptr; compRout: ADBCompletionUPP; buffer: Ptr; commandNum: INTEGER): OSErr;
  118. FUNCTION CountADBs: INTEGER;
  119.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  120.     INLINE $A077, $3E80;
  121.     {$ENDC}
  122. FUNCTION GetIndADB(VAR info: ADBDataBlock; devTableIndex: INTEGER): ADBAddress;
  123.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  124.     INLINE $301F, $205F, $A078, $1E80;
  125.     {$ENDC}
  126. FUNCTION GetADBInfo(VAR info: ADBDataBlock; adbAddr: ADBAddress): OSErr;
  127.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  128.     INLINE $101F, $205F, $A079, $3E80;
  129.     {$ENDC}
  130. FUNCTION SetADBInfo({CONST}VAR info: ADBSetInfoBlock; adbAddr: ADBAddress): OSErr;
  131.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  132.     INLINE $101F, $205F, $A07A, $3E80;
  133.     {$ENDC}
  134.  
  135. CONST
  136.     uppADBCompletionProcInfo = $007B9802;
  137.     uppADBDeviceDriverProcInfo = $00050802;
  138.     uppADBServiceRoutineProcInfo = $0F779802;
  139.  
  140. FUNCTION NewADBCompletionProc(userRoutine: ADBCompletionProcPtr): ADBCompletionUPP;
  141.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  142.     INLINE $2E9F;
  143.     {$ENDC}
  144.  
  145. FUNCTION NewADBDeviceDriverProc(userRoutine: ADBDeviceDriverProcPtr): ADBDeviceDriverUPP;
  146.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  147.     INLINE $2E9F;
  148.     {$ENDC}
  149.  
  150. FUNCTION NewADBServiceRoutineProc(userRoutine: ADBServiceRoutineProcPtr): ADBServiceRoutineUPP;
  151.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  152.     INLINE $2E9F;
  153.     {$ENDC}
  154.  
  155. PROCEDURE CallADBCompletionProc(buffer: Ptr; refCon: Ptr; command: LONGINT; userRoutine: ADBCompletionUPP);
  156.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  157.     {To be implemented:  Glue to move parameters into registers.}
  158.     {$ENDC}
  159.  
  160. PROCEDURE CallADBDeviceDriverProc(devAddress: SInt8; devType: SInt8; userRoutine: ADBDeviceDriverUPP);
  161.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  162.     {To be implemented:  Glue to move parameters into registers.}
  163.     {$ENDC}
  164.  
  165. PROCEDURE CallADBServiceRoutineProc(buffer: Ptr; completionProc: TempADBServiceRoutineUPP; refCon: Ptr; command: LONGINT; userRoutine: ADBServiceRoutineUPP);
  166.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  167.     {To be implemented:  Glue to move parameters into registers.}
  168.     {$ENDC}
  169.  
  170. {$ALIGN RESET}
  171. {$POP}
  172.  
  173. {$SETC UsingIncludes := DeskBusIncludes}
  174.  
  175. {$ENDC} {__DESKBUS__}
  176.  
  177. {$IFC NOT UsingIncludes}
  178.  END.
  179. {$ENDC}
  180.